//
//  NewMyPosListViewController.m
//  NewPro
//
//  Created by RYX on 2019/4/17.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "NewMyPosListViewController.h"
#import "ZJScrollPageView.h"
#import "NewWJHViewController.h"
#import "NewSHZViewController.h"
#import "NewSHSBViewController.h"
#import "NewYKTViewController.h"
#import "NewYJHViewController.h"
#import "NewYDBViewController.h"

@interface NewMyPosListViewController ()<ZJScrollPageViewDelegate>

@property(strong, nonatomic)NSArray *titles;
@property (nonatomic,copy) NSArray *childVcs;
@property (nonatomic, strong) ZJScrollPageView *scrollPageView;
@end

@implementation NewMyPosListViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.navigationController.navigationBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:YES];
    self.navigationController.navigationBar.hidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = BASECOLOR;
    
    ViewHeader *header = [[ViewHeader alloc]initWithBackPOSHeader:@"我的终端列表" Sec:@"回拨"];
    [header setHeaderRightBlock:^{
        
    }];
    [self.view addSubview:header];
    
    //必要的设置, 如果没有设置可能导致内容显示不正常
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    ZJSegmentStyle *style = [[ZJSegmentStyle alloc] init];
    //显示滚动条
    style.showLine = YES;
    // 颜色渐变
    style.gradualChangeTitleColor = YES;
    //    style.scaleTitle = YES;
    style.titleMargin = 35;
    style.segmentHeight = 44;
    
    style.scrollLineColor = [UIColor colorWithRed:12/255.0 green:166/255.0 blue:240/255.0 alpha:1.0];
    style.normalTitleColor = [UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1.0];
    style.selectedTitleColor = [UIColor colorWithRed:12/255.0 green:166/255.0 blue:240/255.0 alpha:1.0];;
    
    self.titles = @[
                    @"未激活",
                    @"审核中",
                    @"审核失败",
                    @"已开通",
                    @"已激活",
                    @"已达标"
                    ];

    NewWJHViewController *VC1 = [[NewWJHViewController alloc] init];
    NewSHZViewController *VC2 = [[NewSHZViewController alloc] init];
    NewSHSBViewController *VC3 = [[NewSHSBViewController alloc] init];
    NewYKTViewController *VC4 = [[NewYKTViewController alloc] init];
    NewYJHViewController *VC5 = [[NewYJHViewController alloc] init];
    NewYDBViewController *VC6 = [[NewYDBViewController alloc] init];
    
    self.childVcs = @[
                      VC1,
                      VC2,
                      VC3,
                      VC4,
                      VC5,
                      VC6
                      ];
    
    // 初始化
    _scrollPageView = [[ZJScrollPageView alloc] initWithFrame:CGRectMake(0, iPhoneX_Top, SCREEN_WIDTH, SCREEN_HEIGHT) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    // 这里可以设置头部视图的属性(背景色, 圆角, 背景图片...)
    //    scrollPageView.segmentView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:_scrollPageView];
}

#pragma ZJScrollPageViewDelegate 代理方法
- (NSInteger)numberOfChildViewControllers {
    return self.titles.count;
}

- (UIViewController<ZJScrollPageViewChildVcDelegate> *)childViewController:(UIViewController<ZJScrollPageViewChildVcDelegate> *)reuseViewController forIndex:(NSInteger)index {
    UIViewController<ZJScrollPageViewChildVcDelegate> *childVc = reuseViewController;
    
    if (!childVc) {
        
        if (index == 0) {
            
            childVc = [[NewWJHViewController alloc] init];
        }else if (index == 1){
            
            childVc = [[NewSHZViewController alloc] init];
        }else if (index == 2){
            
            childVc = [[NewSHSBViewController alloc] init];
        }else if (index == 3){
            
            childVc = [[NewYKTViewController alloc] init];
        }else if (index == 4){
            
            childVc = [[NewYJHViewController alloc] init];
        }else {
            
            childVc = [[NewYDBViewController alloc] init];
        }
        
    }
    

    return childVc;
}


- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    return NO;
}

@end
